<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>添加地址</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no,address=no" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <link rel="stylesheet" href="../css/common.css" />
    <link rel="stylesheet" href="../css/y_index.css" />
    <link rel="stylesheet" href="../js/LArea-master/LArea.min.css">
    <style>
    .area_ctrl {
        background-color: #fff;
    }

    .area_btn {
        color: #555;
    }
    </style>
</head>

<body>
    <div class="bw font15">
        <div class="flex_sb plr24 bdb">
            <span class="col3">收货人</span>
            <input type="text" placeholder="请输入收货人" class="h100 col9 font15 tae" id="name">
        </div>
        <div class="flex_sb plr24 bdb">
            <span class="col3">联系电话</span>
            <input type="tel" placeholder="请输入联系电话" class="h100 col9 font15 tae" oninput="this.value = this.value.replace(/\D/g,'')" id="phone">
        </div>
        <div class="flex_sb plr24 bdb">
            <span class="col3">省/市/区</span>
            <em class="flex_a">
            <input type="text" placeholder="请选择" class="h100 col9 font15 tae mr20" readonly id="city">
            <input id="cityValue" type="text" hidden value=""/>
            <img src="../img/y_arrow_right.png" class="arrow_r" alt="">
        </em>
        </div>
        <div class="plr24 ptb30">
            <p class="col3 mb10">详细地址</p>
            <p>
                <input type="text" placeholder="请输入详细地址" class="col9 font15 w100" id="addr">
            </p>
        </div>
    </div>
    <div class="tab_item mt20 bw flex_sb plr24">
        <div class="font15 col3">设为默认</div>
        <div class="onOff_box flex_a h100">
            <label>
                <input class="mui-switch mui-switch-animbg" type="checkbox" name="onOff" onchange="onOff(this)" id="onOff" checked>
            </label>
        </div>
    </div>
    <div class="main_btn" style="margin-top: .6rem">保存</div>
</body>

</html>
<script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="../js/dlc.js"></script>
<script src="../js/LArea-master/cityData.js"></script>
<script src="../js/LArea-master/LArea.js"></script>
<script>
var status = 1;
$(function() {
    //地址选择
    area('#city', '#cityValue');
    //保存
    $('.main_btn').click(function() {
        console.log(status)
        var name = $('#name').val();
        var phone = $('#phone').val();
        var addr = $('#addr').val();
        var city = $('#city').val(); //地址
        var cityValue = $('#cityValue').val(); //地址id
        console.log(cityValue)
        if (isNull(name)) {
            dlctipbox.show('请输入收货人');
        } else if (isNull(phone)) {
            dlctipbox.show('请输入联系电话');
        } else if (!checkMobileAndTel(phone)) {
            dlctipbox.show('联系电话有误');
        } else if (isNull(city)) {
            dlctipbox.show('请选择省市区');
        } else if (isNull(addr)) {
            dlctipbox.show('请输入详细地址');
        } else {

        }
    });

});

function onOff(obj) {
    if ($(obj).is(':checked')) {
        status = 1;
    } else {
        status = 0;
    }
}

//地址选择
function area(id, valueId) {
    var area = new LArea();
    area.init({
        'trigger': id, //触发选择控件的文本框，同时选择完毕后name属性输出到该位置
        'valueTo': valueId, //选择完毕后id属性输出到该位置
        'keys': {
            id: 'id',
            name: 'name'
        }, //绑定数据源相关字段 id对应valueTo的value属性输出 name对应trigger的value属性输出
        'type': 1, //数据源类型
        'data': cityData //数据源
    });
}
</script>